//Ta Duc Viet
//So sanh 2 xau ki tu
#include <iostream>
#include <string>
using namespace std;
int str_com (char *, char *);
//Tra ve 1 neu xau thu 1 lon hon
//Tra ve -1 neu xau thu 1 nho hon
//Tra ve 0 neu 2 xau bang nhau
int main(){
	char str_1 [80], str_2 [80];
	cout << "So sanh 2 xau ki tu" << endl;
	cout << "Nhap xau thu 1:";
	cin.getline (str_1, 80);
	cout << "Nhap xau thu 2:";
	cin.getline (str_2, 80);
	if ( str_com ( str_1, str_2) < 0) cout << "Xau thu 1 nho hon xau thu 2";
	else if ( str_com ( str_1, str_2) == 0 ) cout << "Xau thu 1 bang xau thu 2";
	else cout << "Xau thu 1 lon hon xau thu 2";
	cout << endl;
	system ("pause");
	return 0;
}
int str_com (char *str_1, char *str_2){
	for ( int i = 0; ; i++){
		if ( str_1[i] > str_2[i]) return 1;
		if ( str_1[i] < str_2[i]) return - 1;
		if ( str_1[i] == '\0' && str_2[i] != '\0') return - 1;
		if ( str_1[i] != '\0' && str_2[i] == '\0') return 1;
		if ( str_1[i] == '\0' && str_2[i] == '\0') return 0;
	}
}
